package com.lagou.edu.course.controller;

import com.lagou.edu.course.api.dto.LessonDTO;
import com.lagou.edu.course.remote.LessonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 课程课时Controller
 *
 * @author lm
 * @since 2021/10/29 13:33
 */
@RestController
@RequestMapping("/course/lesson")
public class LessonController {
    @Autowired
    LessonService lessonService;

    /**
     * 保存或者更新课程
     * @param lessonDTO
     * @return
     */
    @PostMapping(value = "/saveOrUpdate")
    boolean saveOrUpdate(@RequestBody LessonDTO lessonDTO){
        return lessonService.saveOrUpdate(lessonDTO);
    }

    /**
     * 通过lessonId获取课时
     * @param lessonId
     * @return
     */
    @GetMapping(value = "/getById")
    LessonDTO getById(@RequestParam("lessonId") Integer lessonId){
        return lessonService.getById(lessonId);
    }
}
